<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="webjars/Semantic-UI/2.4.1/semantic.css" rel="stylesheet">
    <link href="webjars/datatables/1.10.20/css/dataTables.semanticui.css" rel="stylesheet">
    <link href="webjars/datatables-buttons/1.6.1/css/buttons.semanticui.css" rel="stylesheet">
    <link href="css/responsive.semanticui.min.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">
    <script src="webjars/jquery/3.4.1/jquery.min.js"></script>
    <script src="webjars/Semantic-UI/2.4.1/semantic.js"></script>
    <script src="webjars/datatables/1.10.20/js/jquery.dataTables.js"></script>
    <script src="webjars/datatables/1.10.20/js/dataTables.semanticui.js"></script>
    <script src="webjars/datatables-buttons/1.6.1/js/dataTables.buttons.js"></script>
    <script src="webjars/datatables-buttons/1.6.1/js/buttons.semanticui.js"></script>
    <script src="webjars/datatables-responsive/2.2.3/js/dataTables.responsive.js"></script>
    <script src="webjars/datatables-responsive/2.2.3/js/responsive.semanticui.js"></script>
    <script src="js/main.js"></script>
    <title>Сообщения</title>
</head>
<body>
<div class="ui container">
    <div th:insert="~{header :: header}"></div>
    <div class="ui segment">
        <table id="table" class="ui celled table responsive nowrap unstackable" width="100%">
            <thead>
            <tr>
                <th>id</th>
                <th>Чат с пользователем</th>
                <th></th>
            </tr>
            </thead>
        </table>
    </div>
    <div th:insert="~{footer :: footer}"></div>
</div>
<script>
    $(document).ready(function() {
        var table = $("#table").DataTable({
            "searching": false,
            ajax: {
                url: "user/dialogs",
                type: "GET",
                dataSrc: ""
            },
            columns: [
                {"data": "id"},
                {"data": "userTo.name"},
                {
                    "data": "",
                    "render": function (data, type, row) {
                        return '<a class="ui button" href="/chat?dialog_id='+row.id+'&id='+row.userTo.id+'">Просмотр</a>';
                    }
                }
            ],
            columnDefs: [
                {"targets": [0], "visible": false, "searchable": false},
            ],
            lengthChange: false
        });
    });
</script>
</body>
</html>